$(function(){
	
	window.onscroll = function(){
        var t = document.documentElement.scrollTop || document.body.scrollTop;
        if( t >= 80 ) {
            $(".scrollMenu").removeClass("header")
            $(".scrollMenu").addClass("headerActive");
        }else{
            $(".scrollMenu").removeClass("headerActive")
            $(".scrollMenu").addClass("header");
            $(".service").removeClass("active");
        }
    }
	var code_1 = "";
	//选择数据集类型
    $('#dataset_types_1').on('change',function(){
    	object1 = {};
    	object1['table_checkbox']='';//清空过滤
    	object1['y_min']='';
    	object1['y_max']='';
    	object1["model1"] = '';
    	object1["model2"] = '';
    	object1["object1['checkbox1']"] = '';
    	$("#dataset_types_2").data("selectBox-selectBoxIt").remove();//移除数据集
    	$("#dataset_types_4").data("selectBox-selectBoxIt").remove();//移除数据集
    	$("#dataset_types_5").data("selectBox-selectBoxIt").remove();//移除数据集
    	$("#generic_sensor").data("selectBox-selectBoxIt").remove();//移除数据集

    	//document.getElementById("statistical_index").value = "1";
    	document.getElementById("dataset_types_3").innerHTML="";//删除文件
//    	$("#dataset_types_3").innerHTML="";//删除文件
        code_1 = $(this).find("option:selected").attr('code');
        //显示初始化页面
		document.getElementById("gpsMap").style.display = "none";//隐藏文件
		document.getElementById("others").style.display = "";//隐藏文件
		document.getElementById("picture").style.display = "none";//隐藏文件
        if(code_1 == ""){
        	$("#dataset_types_2").data("selectBox-selectBoxIt").add({ value: "0", code: "", sId: "", text: "--请选择--" });
        	$("#dataset_types_4").data("selectBox-selectBoxIt").add({ value: "0", code: "", sId: "", text: "--请选择--" });
        	$("#dataset_types_5").data("selectBox-selectBoxIt").add({ value: "0", code: "", sId: "", text: "--请选择--" });
        	$("#generic_sensor").data("selectBox-selectBoxIt").add({ value: "0", code: "", sId: "", text: "--请选择--" });
        	return ;
        }
        $.get('/data_visual/get_maper/',{ parentid : code_1},function(data){
            var list = eval('('+ data +')')
            var frist = list[0]
            $('#dataset_types_2').attr('code',frist.code)
            $('#dataset_types_2').attr('sId',frist.id)
            $('#dataset_types_2').html('')

            for(var i=0; i < list.length ;i++){
                var obj = list[i];
                //$("#dataset_types_2").append("<option code=\""+obj.code+"\">"+obj.name+"</option>");
                $("#dataset_types_2").data("selectBox-selectBoxIt").add({ value: obj.code, code: obj.code, sId: obj.id, text: obj.maper_name });
            }

            $("#dataset_types_2").trigger("change")
        })
        if(code_1 != '90'){
        	document.getElementById("mechanism").style.display = "none";//隐藏文件
        	document.getElementById("sensor").style.display = "";//
        }else{
        	document.getElementById("mechanism").style.display = "";//
        	document.getElementById("sensor").style.display = "none";//隐藏文件
        }
        //档数据集为泛型传感器时显示设置深度下拉
        if($('#dataset_types_1').val() == '21'){
        	document.getElementById("generic_depth").style.display = "";//隐藏文件
        }else{
        	document.getElementById("generic_depth").style.display = "none";//隐藏文件
        }
        //设置时间默认为时间戳
//        document.getElementById("statistical_index").options[0].selected="selected";
        //时间戳显示与否
        var statistical_index = $('#statistical_index').val();
        if($('#dataset_types_1').val() == '20' || $('#dataset_types_1').val() == '22'){
//        	$("#statistical_index").val(1);
        	document.getElementById("times").style.display = "none";//隐藏文件
        }else{
        	document.getElementById("times").style.display = "";//隐藏文件
        }
       //var statistical_index = $('#statistical_index').val();
    	if(statistical_index == "1" || statistical_index == "2" || $('#dataset_types_1').val() == '20' || $('#dataset_types_1').val() == '22'){
			document.getElementById("dateStart").style.display = "none";//隐藏文件
			document.getElementById("yearDate").style.display = "none";//隐藏文件
			document.getElementById("daysDate").style.display = "none";//隐藏文件
			document.getElementById("WdatePicker").style.display = "";//隐藏文件
    	}
    	else if(statistical_index == "4"){
			document.getElementById("dateStart").style.display = "none";//隐藏文件
			document.getElementById("yearDate").style.display = "";//隐藏文件
			document.getElementById("WdatePicker").style.display = "none";//隐藏文件
			document.getElementById("daysDate").style.display = "none";//隐藏文件
		}
		else if(statistical_index == "5"){
    		document.getElementById("dateStart").style.display = "none";//隐藏文件
    		document.getElementById("yearDate").style.display = "none";//隐藏文件
    		document.getElementById("daysDate").style.display = "";//隐藏文件
    		document.getElementById("WdatePicker").style.display = "none";//隐藏文件
		}
    	else{
    		document.getElementById("dateStart").style.display = "";//隐藏文件
    		document.getElementById("WdatePicker").style.display = "none";//隐藏文件
    		document.getElementById("yearDate").style.display = "none";//隐藏文件
    		document.getElementById("daysDate").style.display = "none";//隐藏文件
    	}
    })

    //选择数据集
    $('#dataset_types_2').on('change',function(){
    	object1['table_checkbox']='';//清空过滤
    	document.getElementById("dataset_types_3").innerHTML="";//删除文件
    	document.getElementById("addFilter_data").innerHTML="";//删除过滤器文件
//    	$("#dataset_types_3").innerHTML="";//删除文件
    	$("#dataset_types_4").data("selectBox-selectBoxIt").remove();//移除数据集
    	$("#dataset_types_5").data("selectBox-selectBoxIt").remove();//移除数据集
    	$("#generic_sensor").data("selectBox-selectBoxIt").remove();//移除数据集
//    	document.getElementById("dataset_types_3").style.display = "none";//隐藏文件
    	var code = $(this).find("option:selected").attr('code');
        if(code == ""){
        	return ;
        }
        if(code_1 == "90"){
	    	$.post('/data_visual/file_names/',{ code : code},function(nameList){
	    		var list = eval('('+ nameList +')')
	    		
	    		for(var i=0; i < list.length ;i++){
	    			var obj = list[i];
	    			$("#dataset_types_3").append("<input class=\"dataset_types_33\" type=\"checkbox\" value=\""+obj+"\" checked>"+obj+"<br>");
	    		}
	    		
	    	})
//        加载设置纬度数据
	    	$.post('/data_visual/get_columns_file/',{ code : code},function(nameList){
	    		var list = eval('('+ nameList +')')
	    		
	    		for(var i=0; i < list.length ;i++){
	    			var obj = list[i];
	    			$("#dataset_types_4").data("selectBox-selectBoxIt").add({ value: obj, code: obj, sId: obj, text: obj });
	    			
	    		}
	    		
	    	})
//    	加载设置深度数据
	    	$.post('/data_visual/get_columns_file/',{ code : code},function(nameList){
	    		var list = eval('('+ nameList +')')
	    		
	    		for(var i=0; i < list.length ;i++){
	    			var obj = list[i];
	    			$("#dataset_types_5").data("selectBox-selectBoxIt").add({ value: obj, code: obj, sId: obj, text: obj });
	    		}
	    		
	    	})
        }//$("#dataset_types_4").val()
        if(code_1 == "21"){
	//    	加载泛型传感器类型
	    	$.post('/data_visual/get_columns_file/',{ code : code},function(nameList){
	    		var list = eval('('+ nameList +')')
	    		
	    		for(var i=0; i < list.length ;i++){
	    			var obj = list[i];
	    			if(obj == "TIMESTAMP"){//去掉时间轴
	    				
	    			}else{
	    				$("#generic_sensor").data("selectBox-selectBoxIt").add({ value: obj, code: obj, sId: obj, text: obj });
	    			}
	    		}
	    		
	    	})
        }
    })
    //清除过滤器条件
    $('#dataset_types_4').on('change',function(){
    	object1['table_checkbox']='';//清空过滤
    	document.getElementById("addFilter_data").innerHTML="";//删除过滤器文件
    })
    //清除过滤器条件
    $('#dataset_types_5').on('change',function(){
    	object1['table_checkbox']='';//清空过滤
    	document.getElementById("addFilter_data").innerHTML="";//删除过滤器文件
    })
        //选择时间
    $('#statistical_index').on('change',function(){
    	var statistical_index = $('#statistical_index').val();
    	if(statistical_index == "1"){
			document.getElementById("dateStart").style.display = "none";//隐藏文件
			document.getElementById("yearDate").style.display = "none";//隐藏文件
			document.getElementById("daysDate").style.display = "none";//隐藏文件
			document.getElementById("WdatePicker").style.display = "";//隐藏文件
    	}
    	else if(statistical_index == "2"){
    		document.getElementById("dateStart").style.display = "none";//隐藏文件
    		document.getElementById("yearDate").style.display = "none";//隐藏文件
    		document.getElementById("daysDate").style.display = "none";//隐藏文件
    		document.getElementById("WdatePicker").style.display = "";//隐藏文件
    	}
    	else if(statistical_index == "4"){
			document.getElementById("dateStart").style.display = "none";//隐藏文件
			document.getElementById("yearDate").style.display = "";//隐藏文件
			document.getElementById("WdatePicker").style.display = "none";//隐藏文件
			document.getElementById("daysDate").style.display = "none";//隐藏文件
		}
		else if(statistical_index == "5"){
    		document.getElementById("dateStart").style.display = "none";//隐藏文件
    		document.getElementById("yearDate").style.display = "none";//隐藏文件
    		document.getElementById("daysDate").style.display = "";//隐藏文件
    		document.getElementById("WdatePicker").style.display = "none";//隐藏文件
		}
    	else{
    		document.getElementById("dateStart").style.display = "";//隐藏文件
    		document.getElementById("WdatePicker").style.display = "none";//隐藏文件
    		document.getElementById("yearDate").style.display = "none";//隐藏文件
    		document.getElementById("daysDate").style.display = "none";//隐藏文件
    	}
    })
/**
 * 查询
 * dataset_types_1 = ''#选择数据集类型
 * dataset_types_2 = ''#选择数据集
 * dataset_types_33 = []#选择文件
 * dataset_types_31 = ''#选择文件
 * dataset_types_4 = ''#设置纬度
 * dataset_types_5 = ''#设置深度
 */
    $('#search123').on('click',function(){
    	var dataset_types_1 = $("#dataset_types_1").val();
    	var dataset_types_2 = $("#dataset_types_2").val();
		var dataset_types_3 = $(".dataset_types_33:checked");
		var dataset_types_33 = '';
		dataset_types_3.each(function(){
			dataset_types_33+=$(this).val()+",";
		});
		var dataset_types_4 = $("#dataset_types_4").val();
		var dataset_types_5 = $("#dataset_types_5").val();
		var dataset_types_6 = $("#dataset_types_6").val();
		document.getElementById("gpsMap").style.display = "none";//隐藏文件
		document.getElementById("others").style.display = "";//隐藏文件
		document.getElementById("picture").style.display = "none";//隐藏文件
		if(dataset_types_1 == "--请选择--"){
			alert("请选择数据集类型!");
			return ;
		}
		if(dataset_types_2 == "--请选择--"){
			alert("请选择数据集!");
			return ;
		}
		if(dataset_types_1 == "90"){
			if(dataset_types_33 == ""){
				alert("请至少选择一个文件!");
				return ;
			}
		}
//		$.get('/data_visual/get_maper/',{ dataset_types_1 : dataset_types_1},function(data){
		$.post('/data_visual/search/',{ dataset_types_1 : dataset_types_1,dataset_types_2 : dataset_types_2,dataset_types_33 : dataset_types_33,dataset_types_4 : dataset_types_4,dataset_types_5 : dataset_types_5,dataset_types_6:dataset_types_6},function(data){
			var data1 = eval('(['+ data +'])')
			var obb ={};
			var d4 = "";
			var d5 = "";
			var d2 = "";
			var dataList = {};
			for(var i=0; i < data1.length ;i++){
    			var obj = data1[i];
    			obb = obj.ob ;
    			d4 = obj.d4 ;
    			d5 = obj.d5 ;
    			d2 = obj.d2 ;
    			dataList = obj.dataList ;
    		}
			var d4_data = obb[d4];
			var d5_data = obb[d5];
			//将查询的数据放入object1中
			object1['latitude'] = d4 ;//纬度
//			object1['latitude_data'] = d4_data ;//纬度值
			object1['depth'] = d5 ;//深度

			if(object1['table_checkbox'].length > 0){
				var ee = object1['table_checkbox'].toString();
	        	var arr = ee.split(",");
	        	var latitude_d = '';
				for(var i = 0; i < arr.length; i=i+2){
					latitude_d = latitude_d + arr[i] + ",";
	            }
				var depth_d = '';
				for (i = 1; i < arr.length; i=i+2){
					depth_d = depth_d + arr[i] + ",";
				}
				//去掉字符串最后一位
				if(latitude_d.length>0)
					latitude_d = latitude_d.substring(0,latitude_d.length-1);
				if(depth_d.length>0)
					depth_d = depth_d.substring(0,depth_d.length-1);				
				object1['latitude_data'] = latitude_d ;//纬度值d4_data bobject1['table_checkbox']
				object1['depth_data'] = depth_d ;//深度值d5_data
			}else{
				object1['latitude_data'] = d4_data ;//纬度值d4_data
				object1['depth_data'] = d5_data ;//深度值d5_data
			}
			object1['d2'] = d2 ;//显示名称
			object1['ob'] = obb ;//显示名称
			//判断统计类型
			var statisticalType = $("#dataset_types_6").val();
			if(statisticalType == "1"){//频率
				//只取纬度值d4_data
				var ary =(object1['latitude_data'].toString()).split(",");
				var res = [];  
//				ary.sort();  //对数组进行排序 
				var obj_depth = {};
				for(var i = 0;i<ary.length;i++){ 
					if(obj_depth[ary[i]] == null){
						obj_depth[ary[i]] = 1 ;
					}else{
						obj_depth[ary[i]] ++ ;
					}
//					var count = 0;  
//					for(var j=i;j<ary.length;j++){  
//						if(ary[i] == ary[j]){  
//						count++; 
//						}  
//					}  
//					res.push([ary[i],count]);  
//					i+=count;  
				}
				var xList = '';
				var yList = '';
				//res 二维数维中保存了 值和值的重复数  
				for(var i in obj_depth)  
				{
					xList = xList + i + ","
					yList = yList + obj_depth[i] + ","
				} 
				//去掉字符串最后一位
				if(xList.length>0)
					xList = xList.substring(0,xList.length-1);
				if(yList.length>0)
					yList = yList.substring(0,yList.length-1);
				//object1['depth'] = "频率";
				object1['latitude_data'] = xList;
				object1['depth_data'] = yList ;
			}
			if(statisticalType == "2"){//累加和
				//只取纬度值d4_data
				var ary_latitude =(object1['latitude_data'].toString()).split(",");
				var ary_depth =(object1['depth_data'].toString()).split(",");
				var res = [];  
				var depth = 0;
				var obj_depth = {};
				for(var i = 0;i<ary_latitude.length;i++){  
					var latitude = 0;
					var count = 0;
					if(obj_depth[ary_latitude[i]] == null){
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						
						obj_depth[ary_latitude[i]] = latitude ;
					}else{
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						obj_depth[ary_latitude[i]] = obj_depth[ary_latitude[i]] + latitude;
					}
				}
				
				var xList = '';
				var yList = '';
				//res 二维数维中保存了 值和值的重复数  
				for(var i in obj_depth)  
				{
					xList = xList + i + ","
					yList = yList + obj_depth[i] + ","
				} 
				//去掉字符串最后一位
				if(xList.length>0)
					xList = xList.substring(0,xList.length-1);
				if(yList.length>0)
					yList = yList.substring(0,yList.length-1);
				object1['latitude_data'] = xList;
				object1['depth_data'] = yList ;
			}
			if(statisticalType == "3"){//平均值
				//只取纬度值d4_data
				var ary_latitude =(object1['latitude_data'].toString()).split(",");
				var ary_depth =(object1['depth_data'].toString()).split(",");
				var res = [];  
				var depth = 0;
				var obj_dep = {};//平均值
				var obj_depth = {};//总和
				var obj_count = {};//出现次数
//				ary.sort(); //对数组进行排序 undefined
				for(var i = 0;i<ary_latitude.length;i++){  
					var latitude = 0;
					var count = 1;
					if(obj_count[ary_latitude[i]] == null){
						obj_count[ary_latitude[i]] = 1;
					}
					if(obj_depth[ary_latitude[i]] == null){
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						
						obj_depth[ary_latitude[i]] = latitude ;
					}else{
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						obj_count[ary_latitude[i]] ++ ;
						obj_depth[ary_latitude[i]] = obj_depth[ary_latitude[i]] + latitude;
					}
					obj_dep[ary_latitude[i]] = obj_depth[ary_latitude[i]]/obj_count[ary_latitude[i]];
				}
				
				var xList = '';
				var yList = '';
				//res 二维数维中保存了 值和值的重复数  
				for(var i in obj_dep)  
				{
					xList = xList + i + ","
					yList = yList + obj_dep[i] + ","
				} 
				//去掉字符串最后一位
				if(xList.length>0)
					xList = xList.substring(0,xList.length-1);
				if(yList.length>0)
					yList = yList.substring(0,yList.length-1);
				object1['latitude_data'] = xList;
				object1['depth_data'] = yList ;
			}
			if(statisticalType == "4"){//方差
				//只取纬度值d4_data
				var ary_latitude =(object1['latitude_data'].toString()).split(",");
				var ary_depth =(object1['depth_data'].toString()).split(",");
				var res = [];  
				var depth = 0;
				var obj_cha = {};//方差
				var obj_c = {};//方差
				var obj_dep = {};//平均值
				var obj_depth = {};//总和
				var obj_count = {};//出现次数
//				ary.sort(); //对数组进行排序 undefined
				for(var i = 0;i<ary_latitude.length;i++){  
					var latitude = 0;
					var count = 1;
					if(obj_count[ary_latitude[i]] == null){
						obj_count[ary_latitude[i]] = 1;
					}
					if(obj_cha[ary_latitude[i]] == null){
						obj_cha[ary_latitude[i]] = "";
					}
					if(obj_depth[ary_latitude[i]] == null){
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						
						obj_depth[ary_latitude[i]] = latitude ;
					}else{
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							latitude = latitude ;
						}else{
							latitude = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						obj_count[ary_latitude[i]] ++ ;
						obj_depth[ary_latitude[i]] = obj_depth[ary_latitude[i]] + latitude;
					}
					obj_dep[ary_latitude[i]] = obj_depth[ary_latitude[i]]/obj_count[ary_latitude[i]];
					obj_cha[ary_latitude[i]] = obj_cha[ary_latitude[i]] + ary_depth[i] + ",";
					count++;
				}
				var xChaList = '';
				var yChaList = '';
				var xChaListX = [];
				var yChaListY = [];
				var xList = '';
				var yList = '';
				//res 二维数维中保存了 值和值的重复数  
				var variance = {};
				for(var i in obj_dep)  
				{
					xChaList = i ;
					yChaList = (obj_cha[i].toString()).substring(0,obj_cha[i].length-1);
					yChaListY = yChaList.split(",");
					var sum_c = 0;
					var j = 0 ;
					for(j = 0;j<yChaListY.length;j++){
						var n = Number(yChaListY[j]);
						var num = 0;
						if (isNaN(n)){//判断不为数字的给0
							num = 0 ;
						}else{
							num = parseFloat(yChaListY[j]);//将字符串转换成数字
						}
						var n_p = Number(obj_dep[i]);
						var num_p = 0;
						if (isNaN(n_p)){//判断不为数字的给0
							num_p = 0 ;
						}else{
							num_p = parseFloat(obj_dep[i]);//将字符串转换成数字
						}
						
						sum_c = sum_c + (num - num_p)*(num - num_p);
					}
					variance[i] = sum_c/j ;
					
				} 
				var xList = '';
				var yList = '';
				//res 二维数维中保存了 值和值的重复数  
				for(var i in variance)  
				{
					xList = xList + i + ","
					yList = yList + variance[i] + ","
				}
				//去掉字符串最后一位
				if(xList.length>0)
					xList = xList.substring(0,xList.length-1);
				if(yList.length>0)
					yList = yList.substring(0,yList.length-1);
				object1['latitude_data'] = xList;
				object1['depth_data'] = yList ;
			}
			//*********************************************************
			//Y轴初始值和结束值
			var y_min = 0;
			var y_max = 0;
			if(statisticalType == "1" || statisticalType == "2" || statisticalType == "3" || statisticalType == "4"){
				if(object1['y_max'].length > 0 && object1['y_min'].length > 0){
					y_min = parseFloat(object1['y_min']);
					y_max = parseFloat(object1['y_max']);
					var ary_latitude =(object1['latitude_data'].toString()).split(",");
					var ary_depth =(object1['depth_data'].toString()).split(",");
					var depth = 0;
					var obj_depth = {};
					for(var i = 0;i<ary_latitude.length;i++){
						var n = Number(ary_depth[i]);
						if (isNaN(n)){//判断不为数字的给0
							depth = depth ;
						}else{
							depth = parseFloat(ary_depth[i]);//将字符串转换成数字
						}
						if(depth >= y_min && depth <= y_max){
							obj_depth[ary_latitude[i]] = ary_depth[i];
						}
					}
					var xList = '';
					var yList = '';
					for(var i in obj_depth)  
					{
						xList = xList + i + ","
						yList = yList + obj_depth[i] + ","
					} 
					//去掉字符串最后一位
					if(xList.length>0)
						xList = xList.substring(0,xList.length-1);
					if(yList.length>0)
						yList = yList.substring(0,yList.length-1);
					object1['latitude_data'] = xList;
					object1['depth_data'] = yList ;
				}
			}
			var obje = (object1['depth_data'].toString()).split(",");
			var list_linshi = [] ;
			for(var i=0;i<obje.length;i++ ){
				list_linshi.push(parseFloat(parseFloat(obje[i]).toFixed(2)));
			}
			var yy = '' ;
			for(var i=0;i<list_linshi.length;i++ ){
				yy = yy + list_linshi[i] + "," ;
			}
			//去掉字符串最后一位
			if(yy.length>0)
				object1['depth_data'] = yy.substring(0,yy.length-1);
			//***************************************************
			//生成统计图
			init();
		})
    })
    /**
 * 查询
 * dataset_types_1 = ''#选择数据集类型
 * dataset_types_2 = ''#选择数据集
 * start_time = 开始时间
 * end_time = 结束时间 document.getElementById("WdatePicker").style.display = "none";//隐藏文件
 */
    $('#search18').on('click',function(){
    	var dataset_types_1 = $("#dataset_types_1").val();
    	var dataset_types_2 = $("#dataset_types_2").val();
    	var statistical_index = $('#statistical_index').val();
    	var generic_sensor = $('#generic_sensor').val();
    	if(dataset_types_1 == '20'){
    		document.getElementById("gpsMap").style.display = "";//隐藏文件
    		document.getElementById("others").style.display = "none";//隐藏文件
    		document.getElementById("picture").style.display = "none";//隐藏文件
    	}else if(dataset_types_1 == '22'){
    		document.getElementById("gpsMap").style.display = "none";//隐藏文件
    		document.getElementById("others").style.display = "none";//隐藏文件
    		document.getElementById("picture").style.display = "";//隐藏文件
    	}else{
    		document.getElementById("gpsMap").style.display = "none";//隐藏文件
    		document.getElementById("others").style.display = "";//隐藏文件
    		document.getElementById("picture").style.display = "none";//隐藏文件
    	}
		var start_time = '';
		var end_time = '';
		if(statistical_index != '3'){
			if(statistical_index == '4'){
				start_time = $("#dateStart3").val();
				end_time = $("#dateEnd3").val();
			}
			else if(statistical_index == '5'){
				start_time = $("#dateStart4").val();
				end_time = $("#dateEnd4").val();
			}
			else{
				start_time = $("#dateStart1").val();
				end_time = $("#dateEnd1").val();
			}
		}else{
			start_time = $("#dateStart2").val();
			end_time = $("#dateEnd2").val();
		}
		var statistical_index = $("#statistical_index").val();
		if(dataset_types_1 == "--请选择--"){
			alert("请选择数据集类型!");
			return ;
		}
		if(dataset_types_2 == "--请选择--"){
			alert("请选择数据集!");
			return ;
		}
		if(start_time == ""){
			alert("请选择开始时间!");
			return ;
		}
		if(end_time == ""){
			alert("请选择结束时间!");
			return ;
		}
		if(start_time>end_time){
			alert("结束时间应大于开始时间!");
			return ;
		}
		if(dataset_types_1 == '18' || dataset_types_1 == '21'){
			$.post('/data_visual/search/',{ dataset_types_1 : dataset_types_1,dataset_types_2 : dataset_types_2,start_time : start_time,end_time : end_time,statistical_index:statistical_index,generic_sensor:generic_sensor},function(data){
				var data1 = eval('(['+ data +'])')
				var obb ={};
				var d4 = "";
				var d5 = "";
				var d2 = "";
				var dataList = {};
				for(var i=0; i < data1.length ;i++){
					var obj = data1[i];
//    			obb = obj.ob ;
					d4 = obj.d4 ;
					d5 = obj.d5 ;
					d2 = obj.d2 ;
					dataList = obj.sensor_data ;
					xList = obj.xList ;
					yList = obj.yList ;
				}
				var d4_data = d4;
				var d5_data = d5;
				//将查询的数据放入object1中
				object1['d2'] = d2 ;//显示名称
				object1['latitude'] = d4 ;//纬度
				object1['depth'] = d5 ;//深度
				object1['latitude_data'] = xList ;//纬度值
				object1['depth_data'] = yList ;//深度值
				//生成统计图
				init();
			})
			
		}
		//显示gps地图
		var currentTimestamp = 0;
		var currentMap;
		var isClosed = true;
		var currentPoint;
		if(dataset_types_1 == '20'){
			$("#mapcontainer").show();
			isClosed = false;
			$.post('/data_visual/search/',{ dataset_types_1 : dataset_types_1,dataset_types_2 : dataset_types_2,start_time : start_time,end_time : end_time},function(data){
				var data1 = eval('(['+ data +'])')
				var obb ={};
				var d4 = "";
				var d5 = "";
				var d2 = "";
				var lngs = [];
				var lats = [];
				var timestamps = [];
				var dataList = {};
				for(var i=0; i < data1.length ;i++){
					var obj = data1[i];
//    			obb = obj.ob ;
					d4 = obj.d4 ;
					d5 = obj.d5 ;
					d2 = obj.d2 ;
					dataList = obj.sensor_data ;
					lngs = obj.xList ;//经度
					lats = obj.yList ;//维度
					timestamps = obj.temTime ;//时间
				}
				document.getElementById("gpscgq").innerHTML="";//删除文件
				$('#gpscgq').append(d2);
				var map = new BMap.Map("mapcontainer");
				currentMap = map;
				var pointArr = [];
				for(var i = 0;i < lngs.length;i++)
				{
					var point = new BMap.Point(lngs[i], lats[i]);
					var date = (new Date(parseFloat(timestamps[i]))).format("yyyy/MM/dd hh:mm:ss");
		            var marker = new BMap.Marker(point,{title:date});
		            if(i == 0)
		            {
		            	currentTimestamp = parseFloat(timestamps[i]);
			            map.addControl(new BMap.NavigationControl()); //左上角控件
			            map.enableScrollWheelZoom(); //滚动放大
			            map.enableKeyboard(); //键盘放大
		            	map.centerAndZoom(point, 13); //绘制地图
		            	currentPoint = point;
		            }
		            pointArr.push(point);
		            map.addOverlay(marker); //标记地图
				}
				
				var polyline = new BMap.Polyline(pointArr, {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5});
				                                map.addOverlay(polyline);
				//setTimeout(getPoint(),5000);
				//getPoint(dataset_types_1,dataset_types_2,start_time,end_time);
			})
			
			
			
			
		}
		//显示图片
		if(dataset_types_1 == '22'){
			document.getElementById("picture_show").innerHTML="";//删除文件
			$.post('/data_visual/search/',{ dataset_types_1 : dataset_types_1,dataset_types_2 : dataset_types_2,start_time : start_time,end_time : end_time},function(data){
				var data1 = eval('(['+ data +'])')
				var obb ={};
				var d4 = "";
				var d5 = "";
				var d2 = "";
				var imgs = [];
				var timestamps = [];
				var dataList = {};
				for(var i=0; i < data1.length ;i++){
					var obj = data1[i];
//    			obb = obj.ob ;
					d4 = obj.d4 ;
					d5 = obj.d5 ;
					d2 = obj.d2 ;
					dataList = obj.sensor_data ;
					imgs = obj.imgs ;//图片地址
					timestamps = obj.temTime ;//时间
					code = obj.code;//code
				}
				document.getElementById("tpcgq").innerHTML="";//删除文件
				$('#tpcgq').append(d2);//添加
				for(var i=0; i < timestamps.length ;i++){
					// <li class="span2">
     //                        <a class="thumbnail lightbox_trigger" href="images/gallery/imgbox3.jpg">
     //                            <img src="images/gallery/imgbox3.jpg" alt="">
     //                        </a>
     //                    </li>
					$('#picture_show').append('<li class=""><a class="thumbnail lightbox_trigger" href="javascript:;" aa="/data_center/download_file/?code='+code+'&file_name='+imgs[i]+'" title="'+timestamps[i]+'"><img alt="" style="width: 200px; height: 200px" src="/data_center/download_file/?code='+code+'&file_name='+imgs[i]+'" /></a></li>');
					//$('#picture_show').append('<a rel="example_group" href="/static/img/skies.jpg"><img alt="" style="width: 200px; height: 200px" src="/data_center/download_file/?code='+code+'&file_name='+imgs[i]+'" /></a>');
				}
				
			})
		}
    })
//    添加X轴过滤器
    $("#addFilter_x").click(function(){
    	var dataset_types_1 = $("#dataset_types_1").val();
    	var dataset_types_2 = $("#dataset_types_2").val();
		var dataset_types_3 = $(".dataset_types_33:checked");
		var dataset_types_33 = '';
		dataset_types_3.each(function(){
			dataset_types_33+=$(this).val()+",";
		});
		//去掉字符串最后一位
		if(dataset_types_33.length>0)
			dataset_types_33 = dataset_types_33.substring(0,dataset_types_33.length-1);
		var dataset_types_4 = $("#dataset_types_4").val();
		var dataset_types_5 = $("#dataset_types_5").val();
		var dataset_types_6 = $("#dataset_types_6").val();
		if(dataset_types_1 == "--请选择--"){
			alert("请选择数据集类型!");
			return ;
		}
		if(dataset_types_2 == "--请选择--"){
			alert("请选择数据集!");
			return ;
		}
		if(dataset_types_33 == ""){
			alert("请至少选择一个文件!");
			return ;
		}
//		$.get('/data_visual/get_maper/',{ dataset_types_1 : dataset_types_1},function(data){
		$.post('/data_visual/search/',{ dataset_types_1 : dataset_types_1,dataset_types_2 : dataset_types_2,dataset_types_33 : dataset_types_33,dataset_types_4 : dataset_types_4,dataset_types_5 : dataset_types_5,dataset_types_6:dataset_types_6},function(data){
			var data1 = eval('(['+ data +'])')
			var d4 = "";
			var d5 = "";
			var d2 = "";
			var dataList = {};
			for(var i=0; i < data1.length ;i++){
    			var obj = data1[i];
    			obb = obj.ob ;
    			d4 = obj.d4 ;
    			d5 = obj.d5 ;
    			d2 = obj.d2 ;
    			columnListObj = obj.columnListObj ;//判断为什么类型
    			dataList = obj.dataList ;
    		}
			var d4_data = obb[d4];
			var d5_data = obb[d5];
			//将查询的数据放入object1中
			object1['latitude'] = d4 ;//纬度
//			object1['latitude_data'] = d4_data ;//纬度值
//			object1['depth'] = d5 ;//深度
//			object1['depth_data'] = d5_data ;//深度值
//			object1['d2'] = d2 ;//显示名称
			object1['obb'] = obb ;//显示名称
			object1['columnListObj'] = columnListObj ;//判断为什么类型
			//callAs(defaulttheme);
		document.getElementById("table_index").innerHTML="";//删除文件
    	var y = $("#dataset_types_4").val();
    	var ob = object1['obb'];//根据全局变量得到数据
    	var s = ob[y];//达到所有列数据,根据键值得到数据值 
    	var x = $("#dataset_types_5").val();
    	var s5 = ob[x];//达到所有列数据,根据键值得到数据值 
    	$("#table_index").append("<tr><td style=\"width:100px;text-align:center;\"><a href=\"javascript:;\" style=\"color: #0000FF\" id=\"selectAll\" onclick=\"selectAll();\" >全选</a><a href=\"javascript:;\" style=\"color: #0000FF\" id=\"unSelectAll\" onclick=\"unSelectAll();\">反选</a></td><td style=\"width:400px;text-align:center;\">"+y+"</td><td style=\"width:400px;text-align:center;\">"+x+"</td></tr>");
    	for(var i=0;i<s.length;i++){
    		if(i<50)
    			$("#table_index").append("<tr><td style=\"width:100px;text-align:center;\"><input type=\"checkbox\" checked=\"checked\" name=\"table_checkbox\" class=\"table_checkbox\" value=\""+s[i]+","+s5[i]+"\"/></td><td style=\"width:80px;text-align:center;\">"+s[i]+"</td><td style=\"width:80px;text-align:center;\">"+s5[i]+"</td></tr>");
    		else
    			alert("数据太多,现只显示前50条!");
    	}
    	var columnListObj = object1['columnListObj'];
    	if(columnListObj[object1['latitude']] == "FLOAT"){
//    		document.getElementById("addFilterStep").style.display ="";
    		document.getElementById("x_min").disabled="";
    		document.getElementById("stepping").disabled="";
    	}else{
//    		document.getElementById("addFilterStep").style.display ="none";//隐藏
    		document.getElementById("x_min").disabled="disabled";//置灰
    		document.getElementById("stepping").disabled="disabled";//置灰
    	}
        new modal("添加过滤器",$("#addFilterPop").html())
		})
    })
    //X轴过滤提交按钮
    $("#add-addFilter-submit").live("click",function(){
    	document.getElementById("addFilter_data").innerHTML="";//删除过滤器文件
    	//此处table_checkbox的class有2个,需要去掉隐藏的
    	var x_min = $("#x_min").val();//初始值
    	var stepping = $("#stepping").val();//步进值
    	var checkbox = $(".modal-content").find(".table_checkbox:checked");//获取modal-content下的class
    	object1['checkbox1'] = checkbox ;
    	var table_checkbox = '';
		checkbox.each(function(){
			table_checkbox+=$(this).val()+","; 
		});
		//去掉字符串最后一位
		if(table_checkbox.length>0)
			table_checkbox = table_checkbox.substring(0,table_checkbox.length-1);
		object1['table_checkbox'] = table_checkbox ;//Y轴过滤条件
		object1['x_min'] = x_min.trim() ;//Y轴过滤条件
		object1['stepping'] = stepping.trim() ;//Y轴过滤条件
		var latitude_d = '';
		if(object1['table_checkbox'].length > 0){
			var ee = object1['table_checkbox'].toString();
        	var arr = ee.split(",");
			for(var i = 0; i < arr.length; i=i+2){
				latitude_d = latitude_d + arr[i] + ",";
            }
			//去掉字符串最后一位
			if(latitude_d.length>0)
				latitude_d = latitude_d.substring(0,latitude_d.length-1);
		}
		if(table_checkbox != "")
			$("#addFilter_data").append("X轴过滤条件:&#13;&#10;"+latitude_d+";</br>");
		if(x_min.trim() != "" && stepping.trim() != "")
			$("#addFilter_data").append("X轴初始值:"+x_min.trim()+";X轴步进条件:"+stepping.trim()+";");
		object1["model2"] = $(".modal-body").html();
		$('.close').click();//关闭弹框
    })
    
    //    添加Y轴过滤器
    $("#addFilter_y").click(function(){
    	var dataset_types_1 = $("#dataset_types_1").val();
    	var dataset_types_2 = $("#dataset_types_2").val();
		if(dataset_types_1 == "--请选择--"){
			alert("请选择数据集类型!");
			return ;
		}
		if(dataset_types_2 == "--请选择--"){
			alert("请选择数据集!");
			return ;
		}
		if(object1["model1"].length > 0){
			new modal("添加过滤器",$(".addFilterPop_y").html())
			document.getElementById("y_min").value = object1['y_min'] ;//Y轴过滤条件
			document.getElementById("y_max").value = object1['y_max'] ;//Y轴过滤条件
		}
		else
			new modal("添加过滤器",$("#addFilterPop_y").html())
	}) 
	//Y轴过滤提交按钮
    $("#add-addFilter-submit_y").live("click",function(){
    	document.getElementById("addFilter_data_y").innerHTML="";//删除过滤器文件
    	//此处table_checkbox的class有2个,需要去掉隐藏的
    	var y_min = $("#y_min").val();//初始值
    	var y_max = $("#y_max").val();//初始值
		object1['y_min'] = y_min.trim() ;//Y轴过滤条件
		object1['y_max'] = y_max.trim() ;//Y轴过滤条件
		if(y_min.trim() != "" && y_max.trim() == ""){
			alert("请输入结束值");
			return ;
		}
		if(y_min.trim() == "" && y_max.trim() != ""){
			alert("请输入起点值");
			return ;
		}
		if(y_min.trim() != "" && y_max.trim() != "")
			$("#addFilter_data_y").append("Y轴初始值:"+y_min.trim()+";&#13;&#10;Y轴结束值:"+y_max.trim()+";");
		object1["model1"] = $(".addFilterPop_y").html();
		$('.close').click();//关闭弹框
    })
   
});
